<div class="task-edit-inner modal-content-inner">
  <div class="modal-header">
    <h4 class="modal-title">
      <span *ngIf="!model.id">新建任务</span>
      <span *ngIf="model.id">编辑任务</span>
    </h4>

    <button [disabled]="!form.valid || selectedModels.length == 0" (click)="save()" type="button" class="btn btn-primary confirm-btn">保存</button>
    &nbsp;&nbsp;
    <button type="button" class="btn btn-secondary" (click)="dismiss()">取消</button>

  </div>
  <div class="modal-body">
    <form [formGroup]="form" class="my-validate-form form">

      <div class="form-group row">
        <label class="col-2 col-form-label"><span>名称</span></label>
        <div class="col-10">
          <input type="text" class="form-control" name="name" formControlName="name"
                 [(ngModel)]="model.name" #name>
        </div>
      </div>
      <div class="form-group row">
        <label class="col-sm-2 col-form-label">测试环境</label>
        <div class="col-sm-10">
          <select [(ngModel)]="model.envId" formControlName="envId" class="form-control" name="envId">
            <option *ngFor="let entry of envs" value="{{entry.id}}">
              <span>{{entry.label}}</span>
            </option>
          </select>
        </div>
      </div>

      <div class="form-group row">
        <label class="col-2 col-form-label"><span>经办人</span></label>
        <div class="col-10">
          <search-select [(searchModel)]="searchModel" [searchResult]="searchResult" [(selectedModels)]="selectedModels"
                         [selectSingle]='false' (searchChange)="changeSearch($event)">
          </search-select>
        </div>
      </div>

      <div class="form-group row">
        <label class="col-2 col-form-label">
          <span>导入测试集</span><br/>
        </label>
        <div class="col-10">
          <div class="checkbox-list">
            <div class="checkbox-list-inner">
              <div class="toolbar">
                <div class="toolbar-inner">
                  <span (click)="select('all')" class="link">全选</span> |
                  <span (click)="select('none')" class="link">全不选</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  <span class="red">同时只能选中1个项目的测试集, 导入后已有用例将被移除</span>
                </div>
              </div>
              <div>
                <div class="checkbox-list-item title">
                  <label>
                    <span class="checkbox-name">
                      <span class="suite">测试集</span>
                      <span class="project">所属项目</span>
                      <span class="count">用例数</span>
                    </span>
                  </label>
                </div>

                <div *ngFor="let item of suites" class="checkbox-list-item">
                  <label>
                    <span class="checkbox-name">
                      <span class="suite">{{item.name}}</span>
                      <span class="project">{{item.caseProjectName}}</span>
                      <span class="count">{{item.count}}</span>
                    </span>

                    <input (change)="selectSuite(item, $event.target.value)" type="checkbox" class="form-check-input"
                           [(ngModel)]="item.selecting" formControlName="{{'suite-' + item.id}}">
                  </label>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div class="form-group row">
        <label class="col-sm-2 col-form-label"></label>
        <div class="col-sm-10">
          <div class="validate-errors">
            <div class="validate-error" *ngFor="let msg of formErrors">
              <div>{{ msg }}</div>
            </div>
          </div>
        </div>
      </div>

    </form>
  </div>
</div>


